<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="window">
	<div class="window-holder">
		<div class="window-content">
			<div class="breadcrumb green">
				<a href="#" class="active">financialGridView</a>
				<div  class="breadcrum-search">
					<input type="text" id="searchTxt"/>
					<input id="search-button" data-text="searchTxt" type="button" value=""/></div>
				</div>
			</div>

			<div id="financialGridView" style='margin:auto;' class="pq-grid-holder"></div>
		</div>
	</div>
</div>
<c:url var="financialGrid" value="/finance/financialGrid" />
<script>

$(function () {
	
	var colM = [
{dataType: "string", width: 100, dataIndx: "name", title: "Name" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "financialProductCode", title: "Code" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "lowerAmount", title: "Min Amount" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "upperAmount", title: "Max Amount" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "minTerm", title: "Min Term" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "maxTerm", title: "Max Term" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "status", title: "Status" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "productType", title: "Product Type" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "startDate", title: "Start Date" ,editable:false},
	{dataType: "string", width: 100, dataIndx: "expiryDate", title: "Expiry Date" ,editable:false}
	
	];
	  
	var dataModel = {
		        location: "remote",
		        sorting: "remote",
		        
		        dataType: "JSON",
		        method: "GET",
		        curPage: 1,
		        
		        getUrl: function () {
		            var sortDir = (this.sortDir == "up") ? "asc" : "desc";
		            var sort = ['userId', 'userName', 'firstName', 'lastName', 'languageCode', 'userStatus'];
		            return { url: "${financialGrid}", data: "cur_page=" + this.curPage + "&records_per_page=" + 
		                this.rPP + "&sortBy=" + sort[this.sortIndx] + "&dir=" + sortDir };
		        },
		        getData: function (dataJSON) {
		            //var data= 
		          //  	console.log(dataJSON)
		            return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON };                
		        }
		    };
	    var grid1 = $("div#financialGridView").pqGrid({width:"auto", height: 400,
		        dataModel: dataModel,
		        colModel: colM,
		        resizable: true,            
		        columnBorders: true
		        
		    });
	    //for details
	    $.extend(colM[1], {
	    render: function (ui) {
	        var rowData = ui.rowData;
	     
	            
	            return '<a href="javascript:_loadScreenFor(\'/finance/getInputScreen/'+rowData.financialProductId+'\')">' + rowData.financialProductCode+'</a>';
	       
	    }
	  });
	    //for edit
	    $.extend(colM[0], {
	  	  render: function (ui) {
	  	      var rowData = ui.rowData;
	  	   
	  	          return '<a href="javascript:showObjectDetaisl(\'/finance/details/'+rowData.financialProductId+'\')">' + rowData.name+'</a>';
	  	     
	  	  }
	  	});
});
</script>

